<template>
	<view class="content">
		<!-- <u-tabs :list="list" @click="change" :current="xianzaiindex"></u-tabs> -->
		<view class="flexbc li" v-for="item in yue" :key="item.id" >
			<view class="slh" style="flex-grow: 1;">
				<view style="font-size: 32rpx;color: #333;margin-bottom: 20rpx;">{{item.label}}</view>
				<view style="color: #878787;" class="flex">
					<view style="width: 200rpx;" class="slh" v-if="item.activity_name">
						{{item.activity_name}}
					</view>
					<view>
						{{item.created_at}}
					</view>
				  
				</view>
			</view>
			<view style="width: 200rpx;text-align: right; font-size: 30rpx;font-weight: bold;" :style="item.type==1?'color:#FF5B1D':''">{{item.points}}</view>
		</view>
		<!-- <view class="flexbc li" v-for="item in yue.cash_log" :key="item.id" v-if="xianzai == '提现记录'">
			<view class="slh" style="flex-grow: 1;">
				<view style="font-size: 32rpx;color: #333;margin-bottom: 20rpx;">提现</view>
				<view style="color: #878787;">{{item.status_name}}    {{item.created_at}}</view>
			</view>
			<view style="width: 200rpx;text-align: right; font-size: 30rpx; color:#FF5B1D;">-{{item.amount}}</view>
		</view>
		<view class="flexbc li" v-for="item in yue2.reward_other" :key="item.id" v-if="xianzai == '打赏记录'">
			<view class="slh" style="flex-grow: 1;">
				<view style="font-size: 25rpx;color: #333;margin-bottom: 20rpx;">{{item.content}}</view>
				<view style="color: #878787;">{{item.created_at}}</view>
			</view>
			<view style="width: 200rpx;text-align: right;  font-size: 30rpx; color:#FF5B1D;">-{{item.points}}</view>
		</view>
		<view class="flexbc li" v-for="item in yue2.reward_me" :key="item.id" v-if="xianzai == '获赏记录'">
			<view class="slh" style="flex-grow: 1;">
				<view style="font-size: 25rpx;color: #333;margin-bottom: 20rpx;">{{item.content}}</view>
				<view style="color: #878787;">{{item.created_at}}</view>
			</view>
			<view style="width: 200rpx;text-align: right; font-size: 30rpx;">+{{item.points}}</view>
		</view> -->
		
		<u-overlay :show="loading">
			<view class="flexcc" style="width: 100vw;height: 100vh;">
				<u-loading-icon color="#fff" text="加载中..." :vertical="true" textColor="#fff"></u-loading-icon>
			</view>
		</u-overlay>
		<u-toast ref="uToast2"></u-toast>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				yue:"",
				yue2:"",
				loading:true,
				list:[
					{name: '充值记录'},
					{name: '提现记录'},
					{name: '打赏记录'},
					{name: '获赏记录'}
				],
				xianzai:"充值记录",
				xianzaiindex:0
			}
		},
		onLoad(option) {
			
			if(option.index){
				this.xianzaiindex = option.index
				option.index == 0 ? this.xianzai = '充值记录':''
				option.index == 1 ? this.xianzai = '提现记录':''
				option.index == 2 ? this.xianzai = '打赏记录':''
				option.index == 3 ? this.xianzai = '获赏记录':''
			}
			this.getyue()
			this.getyue2()
		},
		computed:{
			
		},
		methods: {
			change:function(item){
				this.xianzai = item.name
				if(item.name == '充值记录'){
					this.getyue()
				}
				if(item.name == '提现记录'){
					this.getyue()
				}
				if(item.name == '打赏记录'){
					this.getyue2()
				}
				if(item.name == '获赏记录'){
					this.getyue2()
				}
			},
			getyue: function() {
				let data = {
					token: uni.getStorageSync('token'),
					page:1,
					page_size:500
				}
				this.yibuget('/api/v1/users/my_account_log',data).then((res)=>{
					this.yue = res.data.data
					this.loading = false
				})
			},
			getyue2: function() {
				let data = {
					token: uni.getStorageSync('token'),
					page:1,
					page_size:500
				}
				this.yibuget('/api/v1/users/my_reward',data).then((res)=>{
					this.yue2 = res.data.data
					this.loading = false
				})
			},
			zzs:function(){
				let x = this.value.toString().replace(/[^0-9]/g,'')
				if(x > this.yue.balance){
					x = this.yue.balance
				}
				this.$nextTick(item=>{
					this.value = x
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.content { background: #F9F9F9; padding: 20rpx; min-height: 100vh;
		.li{ padding: 30rpx 30rpx;  border-bottom:1px #DFDFDF solid;}
	}
</style>
